import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class TopNavigation extends StatelessWidget {
  List navigationList;

  TopNavigation(this.navigationList);

  Widget _gridViewItemUI(BuildContext context, item) {
    return InkWell(
        onTap: () {
          print("点击了");
        },
        child: Container(
          child: Center(
            child: Column(
              children: <Widget>[
                Image.network(
                  item['image'],
                  width: ScreenUtil().setWidth(40),
                ),
                Text(
                  item['mallCategoryName'],
                  style: TextStyle(fontSize: ScreenUtil().setSp(14)),
                )
              ],
            ),
          ),
        ));
  }

  @override
  Widget build(BuildContext context) {
    if (navigationList.length > 10)
      navigationList.removeRange(10, this.navigationList.length);

    return Container(
      color: Colors.white,
      padding: EdgeInsets.all(3),
      height: ScreenUtil().setHeight(190),
      child: GridView.count(
        crossAxisCount: 5,
        //解决  ListView/SingleChildScrollView嵌套GridView滑动冲突
        physics: new NeverScrollableScrollPhysics(),
        children: navigationList.map((item) {
          return _gridViewItemUI(context, item);
        }).toList(),
      ),
    );
  }
}
